<%@ page language="java" import="java.util.*,domain.*"
	pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
	<head>
		<base href="<%=basePath%>">

		<title>My JSP 'Pet_index.jsp' starting page</title>

		<meta http-equiv="pragma" content="no-cache">
		<meta http-equiv="cache-control" content="no-cache">
		<meta http-equiv="expires" content="0">
		<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
		<meta http-equiv="description" content="This is my page">
		<link rel="stylesheet" href="css/style.css" type="text/css"></link>
		<SCRIPT type="text/javascript"><%--
		var XMLHttpReq = false;
 	//创建XMLHttpRequest对象       
    function createXMLHttpRequest() {
    	//Mozilla 浏览器
		if(window.XMLHttpRequest) { 
			XMLHttpReq = new XMLHttpRequest();
		}
		// IE浏览器
		else if (window.ActiveXObject) { 
			try {
				XMLHttpReq = new ActiveXObject("Msxml2.XMLHTTP");
			} catch (e) {
				try {
					XMLHttpReq = new ActiveXObject("Microsoft.XMLHTTP");
				} catch (e) {}
			}
		}
	}
	
	//发送请求函数
	function sendRequest(url) {
		createXMLHttpRequest();
		XMLHttpReq.open("post", url, true);
		//指定响应函数
		XMLHttpReq.onreadystatechange = processResponse;
		// 发送请求
		XMLHttpReq.send(null);  
	}
	// 处理返回信息函数
    function processResponse() {
    	if (XMLHttpReq.readyState == 4) { // 判断对象状态
        	if (XMLHttpReq.status == 200) { // 信息已经成功返回，开始处理信息
            	var res=XMLHttpReq.responseXML.getElementsByTagName("date")[0].firstChild.data;
                window.alert(res);                
            } else {
                window.alert("您所请求的页面有异常。");
            }
        }
    }
	function update(){
		sendRequest('index.jsp');
	}
	function submit()
	{
		document.moneyform.action="OrderSubmit";
        document.moneyform.submit();
	}
		--%></SCRIPT>
	</head>

	<body>
		<%!UserInfo user;%>
		<%
			user = (UserInfo) session.getAttribute("UserLogin");
			if (user == null) {
				response.sendRedirect("GuestLogin.jsp");
			} else {
		%>
		<center>
			<div id="top">
				<%@ include file="top.jsp"%>
			</div>
			<div id="center">
				<div id="centerleft">
					<div id="menulist">
						<!--功能菜单开始-->
						<table width="18%">
							<%
								if (user == null) {
							%>
							<jsp:include page="Login.jsp" />
							<%
								} else {
							%>
							<jsp:include page="LoginOut.jsp" />
							<%
								}
							%>
						</table>
						<!--功能菜单结束-->
					</div>
				</div>
				<div id="centerright">
					<div id="guide">
						您现在所在的位置：宠物在线系统>>后台管理>>宠物管理
					</div>
					<div id="main">
						<!--功能开始-->
						<table width="515" border="0" class="BuyCarShow">
							<tr>
								<th width="59" align="center">
									序号
								</th>
								<th width="122" align="center">
									宠物名称
								</th>
								<th width="91" align="center">
									宠物类别
								</th>
								<th width="91" align="center">
									宠物产地
								</th>
								<th width="130" align="center">
									宠物价格
								</th>
								<th width="40" align="center">
									删除
								</th>
								<th width="40" align="center">
									详情
								</th>
							</tr>
							<%!ArrayList<PetInfo> BuyPets;
	HashMap<UserInfo, ArrayList<PetInfo>> BuyCarSession;%>
							<%
								float Total = 0;
									BuyCarSession = (HashMap<UserInfo, ArrayList<PetInfo>>) session
											.getAttribute("BuyCar");
									BuyPets = BuyCarSession.get(user);
									if (BuyPets == null || BuyPets.size() == 0) {
							%>
							<tr>
								<td colspan="6">
									对不起你没有购物商品！
								</td>
							</tr>
							<%
								} else {
										for (int i = 0; i < BuyPets.size(); i++) {
							%>
							<tr>
								<td><%=i + 1%></td>
								<td><%=BuyPets.get(i).getPet_Name()%></td>
								<td><%=BuyPets.get(i).getPet_ClassName()%></td>
								<td><%=BuyPets.get(i).getPet_Produce_place()%></td>
								<td><%=BuyPets.get(i).getPet_Price()%></td>
								<td>
									<a
										href="ShopPetDelete?id=<%=BuyPets.get(i).getPet_Id()%>&name=<%=BuyPets.get(i).getPet_Name()%>">删除<a>
								</td>
								<td>
									<a
										href="ShopPetShow?id=<%=BuyPets.get(i).getPet_Id()%>&name=<%=BuyPets.get(i).getPet_Name()%>">详情<a>
								</td>
							</tr>
							<%
								Total += BuyPets.get(i).getPet_Price();
										}
							%>
							<tr>
								<td colspan="6" align="right">
									您购物车的总价为：<%=Total%></td>
							</tr>
							<tr>
								<table style="font-size: 12;">
									<tr>
										<td>
											<a href="ShopPet">继续购物</a>
										</td>
										<td>
											|
										</td>
										<td>
										    <%--<form name="moneyform" method="post"><input type="submit" onclick="submit();" value="进行结账"/></form>
											--%><a href="Order?totalmoney=<%=Total%>">进行结账</a>
										</td>
										<td>
											|
										</td>
										<td>
											<a href="ClearShop">清空购物车</a>
										</td>
									</tr>
								</table>
							</tr>
						</table>
						<%
							}
							}
						%>
						<div align="center"></div>
					</div>
				</div>
				<div style="clear: both"></div>
			</div>
		</center>
	</body>
</html>
